<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.5/themes/default/easyui.css"></link>
	<link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.5/themes/icon.css"></link>
	<link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.5/demo/demo.css"></link>
	<script language="JavaScript"  type="text/javascript" src="js/jquery-easyui-1.5/jquery.min.js"></script>
	<script language="JavaScript"  type="text/javascript" src="js/jquery-easyui-1.5/jquery.easyui.min.js"></script>
	<script language="JavaScript"  type="text/javascript" src="js/jquery-easyui-1.5/locale/easyui-lang-zh_CN.js"></script>
<style type="text/css">
	a:link,a:visited{
 		text-decoration:none;  /*超链接无下划线*/
	}
	a:hover{
 		text-decoration:none;  /*鼠标放上去有下划线*/
	}
</style>
	<script type="text/javascript">
	 /*<![CDATA[*/ 
	            
	     function myformatter(date){
			var y = date.getFullYear();
			var m = date.getMonth()+1;
			var d = date.getDate();
			return y+'-'+(m<10?('0'+m):m)+'-'+(d<10?('0'+d):d);
		}
		function myparser(s){
			if (!s) return new Date();
			var ss = (s.split('-'));
			var y = parseInt(ss[0],10);
			var m = parseInt(ss[1],10);
			var d = parseInt(ss[2],10);
			if (!isNaN(y) && !isNaN(m) && !isNaN(d)){
				return new Date(y,m-1,d);
			} else {
				return new Date();
			}
		}
	function showFoodList()
	{
		$.get("/getFoodEvSort", function(data){
				$("#table").datagrid("loadData", data);
			});
	}
	
	 $(document).ready(  
			  function(){
				  
				  var curr_time = new Date(); 
				  $("#sdate").datebox("setValue",myformatter(curr_time)); 
				  $("#edate").datebox("setValue",myformatter(curr_time)); 
				  
				  $("#sdate1").datebox("setValue",myformatter(curr_time)); 
				  $("#edate1").datebox("setValue",myformatter(curr_time));
				  
				  
				  $('#foodname').textbox('textbox').keydown(function (e) {
					  if (e.keyCode == 13) {
						  mysearch();
				      }
				  });
				  
				  
				  mysearch();
					   
			  });
	 
	 function showEv(foodid)
	 {
		 gfoodid = foodid;
		 
		 var sdate = $('#sdate').datebox('getValue');
    	 var edate = $('#edate').datebox('getValue');
    	 
		 
		 $("#sdate1").datebox("setValue",sdate); 
		 $("#edate1").datebox("setValue",edate);
		 
		 
    	 
    	 var url ="/getEvaluateList?sdate="+sdate+"&edate="+edate+"&foodid="+foodid+"&score=1";
    	 $.get(url, function(data){
				$("#table1").datagrid("loadData", data);
		 });
    	 
		 $('#dlg1').dialog('open');
	 }
	 
	 var gfoodid;
	 function mysearch1()
	 {
		 var sdate = $('#sdate1').datebox('getValue');
    	 var edate = $('#edate1').datebox('getValue');
    	 var score = $('#score').combobox('getValue');
    	 
    	 var url ="/getEvaluateList?sdate="+sdate+"&edate="+edate+"&foodid="+gfoodid+"&score="+score;
    	 $('#table1').datagrid('loading');
    	 $.get(url, function(data){
				$("#table1").datagrid("loadData", data);
				$('#table1').datagrid('loaded');
		 });
	 }
	   
	 function progressFormatter1(value,rowData){ 
		return '<a href="#"  onclick="showEv(\''+value+'\')">查&nbsp;看</a>';
	 }
	 
	 function sformate(value,rowData)
	 {
		 
		 if(value=="0")
		 {
			return "极差";	 
		 }
		 
		 if(value=="25")
		 {
			return "差";	 
		 }
		 if(value=="50")
		 {
			return "一般";	 
		 }
		 if(value=="75")
		 {
			return "好";	 
		 }
		 if(value=="100")
		 {
			return "极好";	 
		 }
		
		 return value;
	 }
	    
	 	function progressFormatter(value,rowData){  
	 		  var tempval=parseInt(value);  
	 	        var htmlstr = '<div class="easyui-progressbar progressbar" style="width: 100%; height: 20px;" value="'+tempval +'" text="'+tempval+'%">'+  
	 	        '<div class="progressbar-text" style="width: 100%; height: 20px; line-height: 20px;"></div>'+  
	 	            '<div class="progressbar-value" style="width: '+tempval+'%; height: 20px; line-height: 20px;">'+  
	 	                '<div class="progressbar-text" style="width: 100%; height: 20px; line-height: 20px;">'+tempval+'%</div>'+  
	 	            '</div>'+  
	 	        '</div>';  
	 	        return htmlstr;   
		}  
	 	
	 	function mysearch()
	 	{
	 		 var sdate = $('#sdate').datebox('getValue');
	    	 var edate = $('#edate').datebox('getValue');
	    	 var foodname = encodeURIComponent($('#foodname').val());
	    	 

			 $('#table').datagrid('loading');
	    	 var url = "/getFoodEvSort?sdate="+sdate+"&edate="+edate+"&foodname="+foodname;
	    	 $.get(url, function(data){
					$("#table").datagrid("loadData", data);
					$('#table').datagrid('loaded');
				});
	    	 
	 	}
	 	/*]]>*/  
	</script>
	
	
</head>
<body>

<div style="position:absolute;left:0px;top:0px;width:100%;height:100%" id="pp1">
<table id="table" class="easyui-datagrid" title="菜品评价排行" style="width:800px;height:100%;"
			data-options="singleSelect:true,collapsible:false,rownumbers: true,toolbar:'#tb'">
		<thead>
			<tr>
				<th data-options="field:'foodname'" width="20%">菜品</th>
				<th data-options="field:'count'" width="10%">评价次数</th>
				<th data-options="field:'score',formatter:progressFormatter" width="60%">好评</th>
				<th data-options="field:'id',align:'center',formatter:progressFormatter1" width="10%">详情</th>
			</tr>
		</thead>
	</table>
</div>

<div id="tb" style="padding:2px 5px;">
		起始日期: <input class="easyui-datebox" id="sdate" data-options="formatter:myformatter,parser:myparser" style="width:95px"/>
		截至日期: <input class="easyui-datebox" id="edate" data-options="formatter:myformatter,parser:myparser" style="width:95px"/>
		菜品名:<input class="easyui-textbox" data-options="prompt:'按回车查询'" name ="foodname"  id="foodname" style="width:80px"/>
		<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="mysearch()">查询</a>
	</div>

<div id="dlg1" class="easyui-dialog" title="评价详情" data-options="closed:true,modal:true"  style="width:800px;height:400px;">
	<table id="table1" class="easyui-datagrid"  style="width:100%;height:100%;"
			data-options="singleSelect:true,collapsible:false,rownumbers: true,toolbar:'#tb1'">
		<thead>
			<tr>
				<th data-options="field:'foodname'" width="15%">菜品</th>
				<th data-options="field:'evdate'" width="10%">日期</th>
				<th data-options="field:'score',formatter:sformate" width="10%">评分</th>
				<th data-options="field:'remark'" width="65%">建议</th>
			</tr>
		</thead>
	</table>
</div>

<div id="tb1" style="padding:2px 5px;">
		起始日期: <input class="easyui-datebox" id="sdate1" data-options="formatter:myformatter,parser:myparser" style="width:95px"/>
		截至日期: <input class="easyui-datebox" id="edate1" data-options="formatter:myformatter,parser:myparser" style="width:95px"/>
		评分:<select class="easyui-combobox" id="score" style="width:60px" panelHeight="auto">
				<option selected="selected" value="1">全部</option>
				<option value="0">极差</option>
				<option value="25">差</option>
				<option value="50">一般</option>
				<option value="75">好</option>
				<option value="100">极好</option>
			</select>
		<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="mysearch1()">查询</a>
	</div>
	
</body>
</html>